package com.learn.worksession.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @program: loginproject
 * @description
 * @author: luffy
 * @create: 2020-08-13 01:22
 */
@Controller
@RequestMapping("/login")
public class LoginController {
    @RequestMapping("/toLogin")
    public String login() {
        return "login";
    }


    @RequestMapping("loginSystem")
    public String loginSystem(String username, String password, HttpSession session) {
        String magic = "admin";
        if (magic.equals(username) && magic.equals(password)) {
            session.setAttribute("username", username + System.currentTimeMillis());
            return "redirect:/result/result";
        } else {
            return "redirect:/login/toLogin";
        }
    }



}
